package com.ch.web.service.impl;

import com.ch.web.service.ThreadPoolService;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Component
public class ThreadPoolServiceImpl   implements ThreadPoolService {
    private ThreadPoolExecutor executor;

    @PostConstruct
    public void setExecutor() {
        LinkedBlockingQueue<Runnable> linkedBlockingQueue = new LinkedBlockingQueue<>();
        this.executor = new ThreadPoolExecutor(10, 20, 1, TimeUnit.SECONDS, linkedBlockingQueue);
    }

    public ThreadPoolExecutor getExecutor() {
        return executor;
    }
}
